import java.util.*;

class Student {
    int age;
}

public class TestDemo {

    public static List<String> topKFr(String[] words, int k) {
        Map<String, Integer> map = new TreeMap<>();

        for (String word : words) {
            if (map.get(word) == null) {
                map.put(word, 1);
            }else {
                int val = map.get(word);
                map.put(word, val+1);
            }
        }
        PriorityQueue<Map.Entry<String, Integer>> minHeap = new PriorityQueue<>(k, new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                return o1.getValue().compareTo(o2.getValue());
            }
        });

        for (Map.Entry<String, Integer> entry : minHeap) {
            if (minHeap.size() < k) {
                minHeap.offer(entry);
            }else {
                Map.Entry<String, Integer> top = minHeap.peek();
                Integer val = top.getValue();
                if (val.compareTo(entry.getValue()) < 0) {
                    minHeap.poll();
                    minHeap.offer(entry);
                }else if (val.compareTo(entry.getValue()) == 0) {
                    String key = top.getKey();
                    if (key.compareTo(entry.getKey()) > 0) {
                        minHeap.poll();
                        minHeap.offer(entry);
                    }
                }
            }
        }
        List<String> list = new ArrayList<>();
        for (int i = 0; i < k; i++) {
            String key = minHeap.poll().getKey();
            list.add(key);
        }
        Collections.reverse(list);
        return list;
    }

    public static void func(String str1, String str2) {
        Set<Character> set =  new TreeSet<>();
        str2 = str2.toUpperCase();
        for(int i = 0; i < str2.length(); i++) {
            set.add(str2.charAt(i));
        }
        str1 = str1.toUpperCase();
        Set<Character> setBroken = new TreeSet<>();
        for(int i = 0; i < str1.length(); i++) {
            char ch = str1.charAt(i);
            if(!set.contains(ch) && !setBroken.contains(ch)) {
                setBroken.add(ch);
                System.out.print(ch+" ");
            }
        }
    }

    public static void main5(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str1 = scan.nextLine(); // 期望
        String str2 = scan.nextLine();
        func(str1, str2);
    }

    public static void main4(String[] args) {
        // 不能出现重复的数据
        // TreeSet底层是TreeMap
        Set<String> set = new TreeSet<>();
        set.add("hello");
        set.add("hello");
        set.add("world");
        set.add("cold");
        System.out.println(set);
    }

    public static void main3(String[] args) {
        // 不比较不排序
        Map<Student, Integer> map = new HashMap<>();
        map.put(new Student(), 3);
        map.put(new Student(), 5);

    }

    public static void main2(String[] args) {
        // key唯一, value可以重复, key需要可比较
        Map<String, Integer> map = new TreeMap<>();
        map.put("frost", 3);
        map.put("frost", 4);
        map.put("cold", 12);
        map.put("hello", 5);
        System.out.println(map);
    }

    public static void main1(String[] args) {
        BinarySearchTree binarySearchTree = new BinarySearchTree();
        int[] array = {10, 4, 29, 35, 18, 27, 5, 13};
        for (int i = 0; i < array.length; i++) {
            binarySearchTree.insert(array[i]);
        }
        binarySearchTree.inorder(binarySearchTree.root);
        binarySearchTree.remove(10);
        System.out.println();
    }
}
